{% extends 'system_template/public/pop_up_main.html' %}
{% block head %}
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/kindeditor-all.js') }}"></script>
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/lang/zh-CN.js') }}"></script>
    <script>
        KindEditor.ready(function (K) {
            window.editor = K.create('#ad_code', {
                filterMode: false,
                uploadJson: '{{ url_for('sys_bp.upload') }}',
                allowFileManager: false,
                wellFormatMode: true,
                resizeType: 1,
                formatUploadUrl: false
            });
        });
    </script>
{% endblock %}
{% block content %}
    <form class="layui-form">
        {% for foo in form %}
            <div class="layui-form-item">
                <label class="layui-form-label">{{ foo.label }}</label>
                <div class="layui-input-inline">
                    {{ foo }}
                    <div class="layui-form-mid">
                        {% if foo.name=='ad_name' %}
                            广告名称(必填)
                        {% elif foo.name=='ad_end_date' %}
                            广告到期时间(必填)
                        {% elif foo.name=='status' %}
                            开/关(开启显示)
                        {% endif %}
                    </div>
                </div>
            </div>
        {% endfor %}
        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn" id="submit">提交广告</a>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
{% endblock %}
{% block footer %}
    <script>
        $(function () {
            layui.use(['laydate'], function () {
                $ = layui.jquery;
                form = layui.form;
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#ad_end_date' //指定元素
                });
            });
            $('#submit').click(function () {
                editor.sync();
                submit_post()
            })
        });
    </script>
{% endblock %}
